package com.yzh.booksystem.dao;

import com.yzh.booksystem.entity.Book;
import com.yzh.booksystem.utils.Utils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.SQLException;

public class UpdateDao {
    QueryRunner queryRunner = new QueryRunner(Utils.getDataSource());
    public boolean updateBook(Book book) throws SQLException {
        String sql = "update book set price=?,address=?,isbn=? where bookname=?";
        Object[] params = {book.getPrice(), book.getAddress(), book.getIsbn(),book.getBookname()};
        int num = queryRunner.update(sql, params);
        if (num > 0) {
            return true;
        } else {
            return false;
        }
    }
}
